<template>
  <el-dialog :visible.sync="open" @close="close" :title="title" width="80%" append-to-body>
    <el-table :data="list" max-height="250" size="mini">
      <el-table-column prop="attachname" label="名称"> </el-table-column>
      <el-table-column prop="attachsize" label="大小"> </el-table-column>
      <el-table-column prop="attachtype" label="类型"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="downloadFile(scope.row)"> 下载 </el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>
<script>
import dialogMixin from "@/mixins/dialogMixin";
import * as HandleApi from "@/api/response/handle.js";

export default {
  name: "TaskReportAttachDialog",
  mixins: [dialogMixin],
  dicts: ["plantypecode_dict"],
  components: {},
  props: [],
  data() {
    return {
      title: "任务反馈附件",
      list: [],
      taskId: 0,
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    showDialog(taskId) {
      this.taskId = taskId;
      this.getList();
      this.open = true;
    },
    getList() {
      HandleApi.getTaskReportAttachs(this.taskId).then(res => {
        if (res.data != null) {
          this.list = res.data;
        }
      });
    },
    downloadFile(row) {
      this.download(`com/ComAttach/download/${row.attachid}`, {}, `${row.attachname}.${row.attachtype}`);
    },
  },
};
</script>
<style></style>
